$(function () {
    let id=localStorage.getItem("newsId");
    newsFindById(id);
})
function newsFindById(id) {
    let data=myAjax("/back/news/newsFindById",{id: id},"get");
    setData(data.newsModel);
}
function setData(data) {
    $("#id").val(data.id);
    $("#title").val(data.title);
    $("#date").val(data.date);
    $("#author").val(data.author);
    $("#content").val(data.content);
    $("#newstype").val(data.newstype);
    $("#detailed").val(data.detailed);
}
function newsuapdate() {
    let data={
        id:localStorage.getItem("newsId"),
        title:$.trim($("#title").val()),
        date:$.trim($("#date").val()),
        author:$.trim($("#author").val()),
        content:$.trim($("#content").val()),
        newstype:$.trim($("#newstype").val()),
        detailed:$.trim($("#detailed").val()),

    }
    let da=myAjax("/back/news/newsUpdate",data,"post");
    if (da.count==1){
        alert("修改成功")
        $('#reght').load('/back/news/newsFindAll.html')//刷新一次页面
    } else {
        alert("修改失败")
    }
}